package logController;

import java.util.Calendar;

/**
 * 
 * @author Francisco J. Martínez
 * @date Apr. 19, 2012
 * This class represent the basic element of the log. A LogMessage is that:
 * a message for the log.
 * This class contains a String to save the message, a Timestamp to store the date an time
 * and a EnumType to catalog the different messages. 
 */
public class LogMessage {
	//private Time mDateTime;
	private Calendar mDateTime;
	private String mText;
	private EnumMessageType mType;
	
	public LogMessage(EnumMessageType type, String text){
		
		mType = type;
		// Duplicate the String 
		mText = new String(text);
		// Create a new TimeStamp for current Time
		//mDateTime = new Timestamp(System.currentTimeMillis());
		
		mDateTime = Calendar.getInstance();
	}
	
	/**
	 * @return True if Debug mode is already activated
	 */
	public boolean isDebug(){
		return mType.isDebug();
	}
	
	public String toString(){
		return "["+getTime()+"]"+" "+mText;
	}
	
	private String getTime(){
		String res="";
		res=res+mDateTime.get(Calendar.HOUR_OF_DAY)+
				":"+mDateTime.get(Calendar.MINUTE)+
				":"+mDateTime.get(Calendar.SECOND);
		return res;
	}
}
